"""
Material properties of objects.
"""
__all__=["Material"]

from OpenGL.GL import *

defaultMaterialDiffuse = (0.8, 0.8, 0.8, 1.0)
defaultMaterialAmbient = (0.2, 0.2, 0.2, 1.0)
defaultMaterialSpecular = (0,0,0,1)
defaultMaterialEmission = (0,0,0,1)
defaultMaterialShininess = 0

class Material(object):
    "A Material Object with properties for the Phong Model."
     
    def __init__(self,face=GL_FRONT,
                 diffuse=defaultMaterialDiffuse,
                 ambient=defaultMaterialAmbient,
                 specular=defaultMaterialSpecular,
                 emission=defaultMaterialEmission,
                 shininess=defaultMaterialShininess):
        """Constructor.
        @param face: which face side this material should be attached to (GL_FRONT,
        GL_BACK or GL_FRONT_AND_BACK)
        @param ambient: ambient parameters (4-float vector)
        @param specular: specular parameters (4-float vector)
        @param diffuse: diffuse parameters (4-float vector)
        @param emission: emission parameters (4-float vector)
        @param shininess: cosine power for specular highlights (int)
        """
        self.diffuse = diffuse
        self.ambient = ambient
        self.specular = specular
        self.shininess = shininess
        self.emission = emission
        self.face = face

    def draw(self):
        "Renders the object."
        glMaterialfv (self.face, GL_DIFFUSE,self.diffuse)
        glMaterialfv (self.face, GL_AMBIENT,self.ambient)
        glMaterialfv (self.face, GL_SPECULAR,self.specular)
        glMaterialfv (self.face, GL_EMISSION,self.emission)
        glMaterialf (self.face, GL_SHININESS,self.shininess)

if __name__=="__main__":
    # A simple test
    material = Material()
